/*
 * @Author: 杨涛 2749552387@qq.com
 * @Date: 2024-10-24 15:20:59
 * @LastEditors: 杨涛 2749552387@qq.com
 * @LastEditTime: 2024-10-28 17:52:21
 * @FilePath: \node-modbus\utils\logger.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
// 请求日志
var moment = require('moment')
const logger = (req,res,next) =>{
    // const time = new Date().toLocaleString();
    // moment.locale('zh-cn')
    const time = moment().format('YYYY年MM月DD日 HH时mm分ss秒');
    const ip = req.ip.length < 8 ? 'ip解析错误' : req.ip;
    console.log(`当前时间：${time} ip: ${ip} 请求方式：${req.method} 路由地址：${req.url}`);
    next();
}

module.exports = {
    logger
}

